import axios from '@/util'; 

import type {
  DeptEntity,
} from './typings';



/**
 * 创建部门 POST /api/dept
 */
export async function post_api_dept (
  data: {
    /** 上级部门 id */
    parentId?: string;
    /** 部门名称 */
    name?: string;
    /** 部门负责人 */
    leader?: string;
    /** 备注 */
    remark?: string;
    /** 排序 */
    orderNum?: number;
  },
  options?: Record<string, any>,
): Promise<DeptEntity> {
  return axios({
    method: 'POST',
    url: `/api/dept`,
    data: {
      ...data,
    },
    ...(options || {}),
  })
}

/**
 * 部门更新 PUT /api/dept
 */
export async function put_api_dept (
  data: {
    /** id */
    id?: string;
    /** 上级部门 id */
    parentId?: string;
    /** 部门名称 */
    name?: string;
    /** 部门负责人 */
    leader?: string;
    /** 备注 */
    remark?: string;
    /** 状态 */
    status?: number;
    /** 排序 */
    orderNum?: number;
  },
  options?: Record<string, any>,
): Promise<any> {
  return axios({
    method: 'PUT',
    url: `/api/dept`,
    data: {
      ...data,
    },
    ...(options || {}),
  })
}

/**
 * 查询部门列表 GET /api/dept/list
 */
export async function get_api_dept_list (
  options?: Record<string, any>,
): Promise<DeptEntity> {
  return axios({
    method: 'GET',
    url: `/api/dept/list`,
    ...(options || {}),
  })
}

/**
 * 删除部门 DELETE /api/dept/{id}
 */
export async function delete_api_dept__id_ (
  pathVars: {
    /**  */
    id: any;
  },
  options?: Record<string, any>,
): Promise<any> {
  return axios({
    method: 'DELETE',
    url: `/api/dept/${pathVars.id}`,
    ...(options || {}),
  })
}
